package com.test.restaurant.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.test.restaurant.dao.CuisineDAO;
import com.test.restaurant.pojo.Cuisine;
import com.test.restaurant.service.CuisineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.List;

/**
 * @author 徒有琴
 */
@Service
public class CuisineServiceImpl implements CuisineService {
    @Autowired
    private CuisineDAO cuisineDAO;

    @Override
    public List<Cuisine> getCuisineList() {
        return cuisineDAO.getCuisineList();
    }

    @Autowired
    private RedisTemplate redisTemplate;

    @PostConstruct
    private void inti() {
        List<Cuisine> list = cuisineDAO.getCuisineList();
        redisTemplate.opsForValue().set("cuisines", list);
    }

    //@PreDestroy
}
